// import com.alibaba.druid.sql.ast.SQLCommentHint;
// import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
// import com.alibaba.druid.sql.ast.statement.SQLLockTableStatement;
// import com.alibaba.druid.sql.dialect.h2.visitor.H2ASTVisitor;
// import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
// import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "MySqlLockTableStatement.h"
#include "../../../../ast/SQLCommentHint.h"
#include "../../../../ast/statement/SQLExprTableSource.h"
#include "../../../h2/visitor/H2ASTVisitor.h"
#include "../../visitor/MySqlASTVisitor.h"
#include "../../../../visitor/SQLASTVisitor.h"
#include "../../../../../utils/instanceof.h"
#include "../../../../../utils/listTran.h"

MySqlLockTableStatement_LockType_ptr MySqlLockTableStatement_LockType::READ = MySqlLockTableStatement_LockType_ptr(new MySqlLockTableStatement_LockType(1 << 0, make_string_ptr("READ")));
MySqlLockTableStatement_LockType_ptr MySqlLockTableStatement_LockType::READ_LOCAL = MySqlLockTableStatement_LockType_ptr(new MySqlLockTableStatement_LockType(1 << 1, make_string_ptr("READ LOCAL")));
MySqlLockTableStatement_LockType_ptr MySqlLockTableStatement_LockType::WRITE = MySqlLockTableStatement_LockType_ptr(new MySqlLockTableStatement_LockType(1 << 2, make_string_ptr("WRITE")));
MySqlLockTableStatement_LockType_ptr MySqlLockTableStatement_LockType::LOW_PRIORITY_WRITE = MySqlLockTableStatement_LockType_ptr(new MySqlLockTableStatement_LockType(1 << 3, make_string_ptr("LOW_PRIORITY WRITE")));

MySqlLockTableStatement_LockType::MySqlLockTableStatement_LockType(uint64_t mask, string_ptr name)
{
  this->name = name;
  this->mask = mask;
}

MySqlLockTableStatement_Item::MySqlLockTableStatement_Item()
{
  hints = std::make_shared<std::list<SQLCommentHint_ptr>>();
}
// @Override
void MySqlLockTableStatement_Item::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlLockTableStatement_Item)))
  {
    acceptChild(visitor, tableSource);
  }
  visitor->endVisit(SharedObject(MySqlLockTableStatement_Item));
}

SQLExprTableSource_ptr MySqlLockTableStatement_Item::getTableSource()
{
  return tableSource;
}

void MySqlLockTableStatement_Item::setTableSource(SQLExprTableSource_ptr tableSource)
{
  if (tableSource != nullptr)
  {
    tableSource->setParent(SharedObject(MySqlLockTableStatement_Item));
  }
  this->tableSource = tableSource;
}

MySqlLockTableStatement_LockType_ptr MySqlLockTableStatement_Item::getLockType()
{
  return lockType;
}

void MySqlLockTableStatement_Item::setLockType(MySqlLockTableStatement_LockType_ptr lockType)
{
  this->lockType = lockType;
}

SQLCommentHint_list_ptr MySqlLockTableStatement_Item::getHints()
{
  return hints;
}

void MySqlLockTableStatement_Item::setHints(SQLCommentHint_list_ptr hints)
{
  this->hints = hints;
}

MySqlLockTableStatement::MySqlLockTableStatement()
{
  items = std::make_shared<std::list<MySqlLockTableStatement_Item_ptr>>();
}
// @Override
void MySqlLockTableStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (instanceof <SQLASTVisitor, H2ASTVisitor>(visitor))
  {
    return;
  }
  MySqlStatementImpl::accept0(visitor);
}

// @Override
void MySqlLockTableStatement::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlLockTableStatement)))
  {
    SQLObject_list_ptr tmp = ListTran::tran_class<MySqlLockTableStatement_Item, SQLObject>(items);
    acceptChild(visitor, tmp);
  }
  visitor->endVisit(SharedObject(MySqlLockTableStatement));
}

MySqlLockTableStatement_Item_list_ptr MySqlLockTableStatement::getItems()
{
  return items;
}

void MySqlLockTableStatement::setItems(MySqlLockTableStatement_Item_list_ptr items)
{
  this->items = items;
}
